//
// Created by root on 6/24/17.
//

#include <stdio.h>
#include <memory.h>
#include "cmocka_test.h"
#include "runner_base.h"
#include "../../src/base/utils.h"

static void test_match_regex() {
    assert_true(match_regex("[a-zA-Z]", "a"));
    assert_true(match_regex("[a-zA-Z]", "Z"));
}

static void test_match_regex_groups() {
    char **strings = match_regex_groups("([0-9]+.[0-9]*e[0-9]+)-([0-9]*)/([0-9]*)i", 4, "3.1e2-5/6i");
    assert_string_equal(*strings, "3.1e2-5/6i");
    assert_string_equal(*(strings + 1), "3.1e2");
    assert_string_equal(*(strings + 2), "5");
    assert_string_equal(*(strings + 3), "6");
    assert_null(*(strings + 4));
}

static void test_get_local_time() {
    char now[32];
    memset(now, 0, sizeof(now));
    get_local_time(now);
    printf("%s\n", now);
    assert_non_null(now);
}

int main(int argc, char **argv) {
    const struct CMUnitTest tests[] = {
            cmocka_unit_test(test_match_regex),
            cmocka_unit_test(test_match_regex_groups),
            cmocka_unit_test(test_get_local_time),
    };
    return cmocka_run_group_tests(tests, setup_base, teardown_base);
}




